const express = require('express');
const router = express.Router();
const question = require('../../bin/control/questionControl');
module.exports =
    router.post('/addQuestion', function (req, res, next) { // 插入文章
      console.log(req.body)
       question.addQuestion(req.body)
       res.send('success')
    });

    router.get('/allQuestion', function (req, res, next) { // 查询所有题目
      question.findAllQuestion((allData)=>{
         res.send(allData)
      })
   });
   router.get('/OneQuestion', function (req, res, next) { // 查询单个题目
      let _id = req.query._id
      question.findOneQuestion(_id,(allData)=>{
         res.send(allData)
      })
   //    console.log(req.body)
   });
   router.post('/deleteQuestion', function (req, res, next) { // 删除文章
      let _id = req.body._id
      question.deleteOneQuestion(_id,(allData)=>{
         res.send('删除成功')
      })
   });
   router.post('/editorQuestion', function (req, res, next) { // 更新文章
      console.log(req.body)
      let data = req.body
      question.updateQuestion(data, (allData) => {
         res.send(allData)
      })
   });
      
